import SwiftUI

struct WithAnimationView: View {
    @State var offsetY: CGFloat = 0
    
    var body: some View {
        VStack {
            Text("With Animation")
            
            Text("Parts of Animation")
            
            Text("...")
            
            // Demo
            // Animation curve
            // 播放一段动画的时候，动画的播放方式
            Circle()
                .foregroundColor(.orange)
                .frame(width: 100, height: 100)
                .offset(x: 0, y: offsetY)
                .animation(Animation.easeIn, value: offsetY)
//                .animation(Animation.default) - deprecated
            
            Spacer()
            
            Button(action: {
                offsetY = offsetY == 400 ? 0 : 400
            }, label: {
                Text("Drop")
            })
            .padding(.bottom)
        }
        .navigationTitle("With animation")
    }
}

